#include <iostream>
#include <algorithm>//next_permutation(s.begin(), s.end());
#include <numeric>//iota()
#include <ranges>//ranges::sort()
#include <bitset>
#include <bit>//std::bit_width()
#include <set>
#include <map>
#include <unordered_map>
#include <vector>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#define ll long long
const int N = 1e5 + 5;
const int M = 6e6 + 5;
const ll mod = 1e9 + 7;
const int INF = 1e9 - 1;
using namespace std;

void solve() {
    int i, j;
    int n, m, k;
    cin >> n >> m;

    string s = "";
    for (i = 0; i < n; i++) s.push_back('(');
    for (i = 0; i < n; i++) s.push_back(')');
    int tpn = n << 1;
    //     cout << tpn << "\n";

    vector<array<int, 2>> lim(m);
    vector<bool> st(tpn);
    if (m == 0) {
        cout << s << "\n"; return;
    }


    for (i = 0; i < m; i++) {
        cin >> lim[i][0] >> lim[i][1];
        lim[i][0]--;
        lim[i][1]--;
    }
    sort(lim.begin(), lim.end(), [](array<int, 2>& x, array<int, 2>& y) {
        if (x[0] == y[0]) return x[1] < y[1];
        return x[0] < y[0];
        });

    int flag = n - 1;
    for (i = m - 1; i >= 0; i--) {
        if (i - 1 >= 0 && lim[i - 1][1] >= lim[i][0]) {
            lim[i - 1][0] = lim[i][0];
            continue;
        }

        int l = lim[i][0];
        if (s[l] == '(') {
            st[l] = 1;
            continue;
        }

        while (flag >= 0 && st[flag]) flag--;
        if (flag < 0) {
            cout << "-1\n"; return;
        }

        swap(s[l], s[flag]);
        st[flag] = 1;
        st[l] = 1;
    }

    int f = 0;
    for (i = 0; i < tpn; i++) {
        f += (s[i] == '(' ? 1 : -1);
        if (f < 0) {
            cout << "-1\n";
            return;
        }
    }

    cout << s << "\n";
}
int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int t = 1;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}